package com.tjnu.losca.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tjnu.losca.Vo.ResponseVO;
import com.tjnu.losca.service.IAdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 意见表 前端控制器
 * </p>
 *
 * @author losca
 * @since 2022-02-14
 */
@RestController
@RequestMapping("/advice")
public class AdviceController {
    @Autowired
    IAdviceService adviceService;
    @GetMapping("/getAll")
    public ResponseVO<IPage> getAll(@RequestParam(defaultValue = "1") int pageNum,
                                    @RequestParam(defaultValue = "8") int pageSize
                                     ){
        return ResponseVO.success(adviceService.getAll(pageNum,pageSize));
    }

    @PostMapping("/del")
    public ResponseVO<Boolean> del(String id){
        return ResponseVO.success(adviceService.del(id));
    }

    @PostMapping("/reply")
    public ResponseVO<Boolean> reply(String username,String email,String reply){
        System.out.println(reply);
        return ResponseVO.success(adviceService.reply(username, email, reply));
    }

}
